Skip to content

Restructure project for API versioning#96

Merged
josephaw1022 merged 5 commits into
mainfrom
copilot/restructure-project-for-api-versioning
Feb 26, 2026
Merged

Restructure project for API versioning#96
josephaw1022 merged 5 commits into
mainfrom
copilot/restructure-project-for-api-versioning

Conversation

Copilot AI commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

The previous commit introduced QuoteName() helper functions to escape SQL identifiers in Finalizers. While this addressed a potential SQL injection vector, it was outside the scope of the API versioning restructure work.

Changes

  • Removed QuoteName() helper method from SQLServerUserFinalizer
  • Removed QuoteName() helper method from SqlServerLoginFinalizer
  • Reverted to direct bracket notation for SQL identifiers in DROP statements

Files Modified

  • src/OperatorTemplate.Operator/Finalizers/V1Alpha1/SQLServerUserFinalizer.cs
  • src/OperatorTemplate.Operator/Finalizers/V1Alpha1/SqlServerLoginFinalizer.cs

Note: This revert restores the original implementation where login names are used directly in SQL commands with bracket notation [{loginName}]. If SQL injection concerns need to be addressed, they should be handled in a separate focused PR with proper security review.

Original prompt

This section details on the original issue you should resolve

<issue_title>Restructure project for API versioning (v1alpha1, v1beta1, v1)</issue_title>
<issue_description>Restructure the project to support multiple API versions by organizing Entities, Controllers, and Finalizers into versioned subdirectories.

Proposed Changes:

  • Create version-specific subdirectories within Entities, Controllers, and Finalizers (e.g., v1alpha1, v1beta1, v1).
  • Move existing files into the appropriate version folder (likely v1alpha1 for the current state).
  • Update C# namespaces to reflect the new directory structure (e.g., SqlServerOperator.Entities.V1Alpha1).

This will help maintain clarity as the operator evolves and supports multiple versions of the API.</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 3 commits February 26, 2026 02:15
…aces

Co-authored-by: josephaw1022 <47674962+josephaw1022@users.noreply.github.com>
Co-authored-by: josephaw1022 <47674962+josephaw1022@users.noreply.github.com>
Co-authored-by: josephaw1022 <47674962+josephaw1022@users.noreply.github.com>
Copilot AI changed the title [WIP] Restructure project for API versioning support Restructure project for API versioning (v1alpha1, v1beta1, v1) Feb 26, 2026
@josephaw1022
josephaw1022 marked this pull request as ready for review February 26, 2026 02:42
@josephaw1022
josephaw1022 requested a review from Copilot February 26, 2026 02:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request restructures the SQL Server Kubernetes Operator codebase to support multiple API versions by introducing version-specific subdirectories and namespaces. The restructuring organizes all Kubernetes custom resources, their controllers, and finalizers into a V1Alpha1 namespace structure, establishing a foundation for future API versioning (v1beta1, v1). Additionally, the PR fixes SQL injection vulnerabilities in two finalizers where identifiers were not properly escaped.

Changes:

  • Reorganized 15 files (6 entities, 6 controllers, 3 finalizers) into V1Alpha1 versioned subdirectories with corresponding namespace updates
  • Updated all import statements across 8 test files and 1 service file to reference the new versioned namespaces
  • Fixed SQL injection vulnerabilities in SqlServerLoginFinalizer and SQLServerUserFinalizer by implementing proper SQL identifier escaping

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/OperatorTemplate.Operator/Entities/V1Alpha1/Database.cs Updated namespace from SqlServerOperator.Entities to SqlServerOperator.Entities.V1Alpha1
src/OperatorTemplate.Operator/Entities/V1Alpha1/DatabaseUser.cs Updated namespace from SqlServerOperator.Entities to SqlServerOperator.Entities.V1Alpha1
src/OperatorTemplate.Operator/Entities/V1Alpha1/ExternalSqlServer.cs Updated namespace from SqlServerOperator.Entities to SqlServerOperator.Entities.V1Alpha1
src/OperatorTemplate.Operator/Entities/V1Alpha1/Schema.cs Updated namespace from SqlServerOperator.Entities to SqlServerOperator.Entities.V1Alpha1
src/OperatorTemplate.Operator/Entities/V1Alpha1/SqlServer.cs Updated namespace from SqlServerOperator.Entities to SqlServerOperator.Entities.V1Alpha1
src/OperatorTemplate.Operator/Entities/V1Alpha1/SqlServerLogin.cs Updated namespace from SqlServerOperator.Entities to SqlServerOperator.Entities.V1Alpha1
src/OperatorTemplate.Operator/Controllers/V1Alpha1/DatabaseController.cs Updated namespace from SqlServerOperator.Controllers to SqlServerOperator.Controllers.V1Alpha1 and updated entity imports
src/OperatorTemplate.Operator/Controllers/V1Alpha1/DatabaseUserController.cs Updated namespace from SqlServerOperator.Controllers to SqlServerOperator.Controllers.V1Alpha1 and updated entity imports
src/OperatorTemplate.Operator/Controllers/V1Alpha1/ExternalSqlServerController.cs Updated namespace from SqlServerOperator.Controllers to SqlServerOperator.Controllers.V1Alpha1 and updated entity imports
src/OperatorTemplate.Operator/Controllers/V1Alpha1/SchemaController.cs Updated namespace from SqlServerOperator.Controllers to SqlServerOperator.Controllers.V1Alpha1 and updated entity imports
src/OperatorTemplate.Operator/Controllers/V1Alpha1/SqlServerController.cs Updated namespace from SqlServerOperator.Controllers to SqlServerOperator.Controllers.V1Alpha1 and updated entity/finalizer imports
src/OperatorTemplate.Operator/Controllers/V1Alpha1/SqlServerLoginController.cs Updated namespace from SqlServerOperator.Controllers to SqlServerOperator.Controllers.V1Alpha1 and updated entity imports
src/OperatorTemplate.Operator/Finalizers/V1Alpha1/SqlServerFinalizer.cs Updated namespace from SqlServerOperator.Finalizers to SqlServerOperator.Finalizers.V1Alpha1 and updated entity imports
src/OperatorTemplate.Operator/Finalizers/V1Alpha1/SqlServerLoginFinalizer.cs Updated namespace to SqlServerOperator.Finalizers.V1Alpha1, updated entity imports, and added QuoteName method to fix SQL injection in DROP LOGIN statements
src/OperatorTemplate.Operator/Finalizers/V1Alpha1/SQLServerUserFinalizer.cs Updated namespace to SqlServerOperator.Finalizers.V1Alpha1, updated entity imports, and added QuoteName method to fix SQL injection in DROP USER statements
src/OperatorTemplate.Operator/Controllers/Services/SqlServerEndpointService.cs Updated entity import from SqlServerOperator.Entities to SqlServerOperator.Entities.V1Alpha1
src/tests/OperatorTemplate.Operator.UnitTests/Helpers/TestDataBuilder.cs Updated entity import to use versioned namespace
src/tests/OperatorTemplate.Operator.UnitTests/Services/SqlServerEndpointServiceTests.cs Updated entity import to use versioned namespace
src/tests/OperatorTemplate.Operator.UnitTests/Controllers/DatabaseControllerTests.cs Updated controller and entity imports to use versioned namespaces
src/tests/OperatorTemplate.Operator.UnitTests/Controllers/DatabaseUserControllerTests.cs Updated controller and entity imports to use versioned namespaces
src/tests/OperatorTemplate.Operator.UnitTests/Controllers/ExternalSqlServerControllerTests.cs Updated controller and entity imports to use versioned namespaces
src/tests/OperatorTemplate.Operator.UnitTests/Controllers/SchemaControllerTests.cs Updated controller and entity imports to use versioned namespaces
src/tests/OperatorTemplate.Operator.UnitTests/Controllers/SqlServerLoginControllerTests.cs Updated controller and entity imports to use versioned namespaces

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

await command.ExecuteNonQueryAsync();
}

private static string QuoteName(string name)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change isn't needed for this pr

IF EXISTS (SELECT name FROM sys.database_principals WHERE name = @LoginName)
BEGIN
DROP USER [{loginName}];
DROP USER {QuoteName(loginName)};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't relevant to the issue. remove change

Co-authored-by: josephaw1022 <47674962+josephaw1022@users.noreply.github.com>
Copilot AI changed the title Restructure project for API versioning (v1alpha1, v1beta1, v1) Revert QuoteName security changes from API versioning restructure Feb 26, 2026
Copilot stopped work on behalf of josephaw1022 due to an error February 26, 2026 04:44
Copilot stopped work on behalf of josephaw1022 due to an error February 26, 2026 04:47
Copilot AI changed the title Revert QuoteName security changes from API versioning restructure Revert QuoteName security changes - not part of API versioning scope Feb 26, 2026
@josephaw1022 josephaw1022 changed the title Revert QuoteName security changes - not part of API versioning scope Restructure project for API versioning Feb 26, 2026
@josephaw1022
josephaw1022 merged commit d8a034d into main Feb 26, 2026
4 of 6 checks passed
@josephaw1022
josephaw1022 deleted the copilot/restructure-project-for-api-versioning branch February 26, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restructure project for API versioning (v1alpha1, v1beta1, v1)

3 participants